test: Add more Sponsor tests#7783
Conversation
5dbe37d to
9c9b66d
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #7783 +/- ##
=======================================
Coverage 82.8% 82.8%
=======================================
Files 1036 1036
Lines 80107 80110 +3
Branches 8932 8931 -1
=======================================
+ Hits 66300 66315 +15
+ Misses 13798 13786 -12
Partials 9 9 🚀 New features to boost your workflow:
|
|
This PR has conflicts, please resolve them in order for the PR to be reviewed. |
9c9b66d to
f234682
Compare
|
All conflicts have been resolved. Assigned reviewers can now start or resume their review. |
| BEAST_EXPECT(a.count() == b.count()); | ||
| BEAST_EXPECT(a < b); | ||
| BEAST_EXPECT(std::max(a, b) == b); | ||
| } |
There was a problem hiding this comment.
sponsored == maxU32 tests missed
|
|
||
| auto const a = makeCounts(3, 1, 2); | ||
| auto const& self = a; | ||
| BEAST_EXPECT(a == self); // self-compare |
| sb2.adjustOwnerCountHook(alice, OwnerCounts(), counts); | ||
|
|
||
| // The parent has no entry for alice yet | ||
| BEAST_EXPECT(sb.ownerCountHook(alice, OwnerCounts()) == OwnerCounts()); |
There was a problem hiding this comment.
aslo sb2 should be tested here
| sb.adjustOwnerCountHook(bob, OwnerCounts(), higher); | ||
| { | ||
| PaymentSandbox sb2(&sb); | ||
| sb2.adjustOwnerCountHook(bob, OwnerCounts(), lower); |
| // fields (Sequence, Fee, ...) must be fixed before the sponsor | ||
| // signs; SponsorSignature and Signers are not signing fields, so | ||
| // later sign_for calls don't invalidate the sponsor's signature. | ||
| auto setupTx = [&]() { |
There was a problem hiding this comment.
Please create accountSet helper, like fset(), and use it more standard way, like
env(accountSet(..), Fee(..), MSIg(...))
| resp.toStyledString()); | ||
| } | ||
| { | ||
| // Signed SponsorSignature (non-empty TxnSignature) |
There was a problem hiding this comment.
same here - why to use direct json editing, when we have a lot of helpers?
| }; | ||
|
|
||
| json::Value tx; | ||
| tx[jss::Account] = alice.human(); |
There was a problem hiding this comment.
Same here - please use UT helpers (Fee(..), SIg(..) Sponsor...)
|
|
||
| // Sponsorship with a reserve budget where prefunded (unsigned) use | ||
| // of the reserve budget requires a sponsor signature. | ||
| env(sponsor::set_reserve(sponsor, tfSponsorshipSetRequireSignForReserve, 10), |
There was a problem hiding this comment.
Named not according to standard, should be setReserve
| // (lsfSponsorshipRequireSignForFee), and a co-signed transaction | ||
| // still draws the fee from the prefunded FeeAmount because | ||
| // getFeePayer prefers the Sponsorship object when it exists. | ||
| env(sponsor::set_fee(sponsor, tfSponsorshipSetRequireSignForFee, XRP(10)), |
There was a problem hiding this comment.
Same - bad name, should be setFee
| // it before the Oracle-specific preflight checks run. | ||
| { | ||
| json::Value oracleSet; | ||
| oracleSet[jss::TransactionType] = jss::OracleSet; |
There was a problem hiding this comment.
Use Oracle helpers, not direct json editing
| checkMetrics(*this, env, 0, 6, 5, 3); | ||
| } | ||
|
|
||
| void |
There was a problem hiding this comment.
please add tests for N transactions with the same sponsor and where N-2-ish transaction's fee exhaust sponsor balance
| Ter(temBAD_REGKEY)); | ||
| env.close(); | ||
| } | ||
| } |
There was a problem hiding this comment.
Missed batch tests which exhaust sponsor / sponsorship balance through fee and reserve (6 txs and sponsor balance depleted on 3d or 4th)
|
|
||
| auto tx = noop(alice); | ||
| tx[sfSponsor.jsonName] = sponsor.human(); | ||
| tx[sfSponsorFlags.jsonName] = static_cast<std::uint32_t>(spfSponsorFee); |
| } | ||
|
|
||
| void | ||
| testFeeOnlySponsorshipObjectRouting() |
There was a problem hiding this comment.
maybe put it next to testCosignedTransferConsumesPrefundedBudget
High Level Overview of Change
This PR adds more tests for Sponsor-related code.
No change to source code, just tests.
Context of Change
Better code testing
API Impact
N/A